
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>员工复职信息查询</title>
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">
    <link rel="stylesheet" href="/css/notice/noticeManagement.css">
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>
        table tbody td{
            text-align: left;
            padding: 10px;
            box-sizing: border-box;
        }
        table tbody td.color{
            padding:10px 10px 10px 50px;
        }
        input{
            float: none;
        }
        .editAndDelete3{
            color: red;
        }
        .color{
            font-size: 11pt;
            color: #2a588c;
            font-weight: bold;
        }
        table tbody td textarea{
            width: 229px;
            height: 34px;
            line-height: 34px;
            padding-left: 10px;
            outline: none;
            border-radius: 4px;
            vertical-align: middle;
            font-family:"Microsoft Yahei";
        }
        table tbody td a{
            vertical-align: middle;
            font-size: 11pt;
        }
        table tbody td select{
            width: 119px;
            height: 28px;
            border-radius: 4px;
        }
        table tbody td input[type=text]{
            width: 288px;
            height: 32px;
            border-radius: 4px;
            padding-left: 10px;
            box-sizing: border-box;
        }
        .btnsava{
            padding:5px 15px;
            border-radius: 4px;
            background: #2F8AE3;
            color: #fff;
        }
        .pagediv .page-bottom-outer-layer table td{
            text-align: left;
        }
        #pagediv{
            width: 100%;
        }
        #pagediv table{
            width: 98%;
            margin: 0 auto;
        }
        #pagediv table tr:nth-child(odd){
            background-color: #F6F7F9;
        }
        #pagediv table tr:nth-child(even){
            background-color: #ffffff;
        }
        #pagediv table tr th{
            padding: 8px;
            font-size: 13pt;
            color: #2F5C8F;
            font-weight: bold;
            text-align: left;
        }
        #pagediv table tr td{
            padding: 8px;
            font-size: 11pt;
            text-align: left;
        }
        /*table tr.borderNone{*/
        /*border:none;*/
        /*}*/
    </style>
</head>
<body>
<div class="navigation">
    <img src="/img/commonTheme/${sessionScope.InterfaceModel}/gonggaochaxun.png" alt="">
    <h2>员工复职信息查询</h2>
</div>
<div class="query">
    <div class="header"><fmt:message code="global.lang.inputquerycondition"/></div>
    <form id="ajaxform" action="">
        <input type="hidden" name="changeId" value="1">
        <input type="hidden" name="exportId" value="">
        <table style="width: 100%;    border: 1px solid #c0c0c0;
    border-top: none;">
            <tbody>
            <tr class="borderNone">
                <td width="30%" class="color">复职人员：</td>
                <td width="70%">

                    <textarea name="" class="theControlData" readonly="readonly" id="personnel" style="width: 165px;" rows="2"></textarea>
                    <a style="margin-left:5px;" href="javascript:;" class="addControls" data-type="3"><fmt:message code="global.lang.add"/></a>
                    <a href="javascript:;" style="color: red" class="cleardate"><fmt:message code="global.lang.empty"/></a>

                </td>
            </tr>

            <tr class="borderNone">
                <td width="30%" class="color">复职类型：</td>
                <td width="70%">
                    <select name="rehabType" id="rehabType">
                        <option value=""><fmt:message code="hr.th.PleaseSelect" /></option>
                    </select>
                </td>
            </tr>

            <tr class="borderNone">
                <td width="30%" class="color">申请日期：</td>
                <td width="70%">
                    <input type="text" id="applyDataBef" style="width: 158px;height:28px;" name="transferDate" size="12" maxlength="10" class="BigInput" value="" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"/>
                    至
                    <input type="text" id="applyDataAft" style="width: 158px;height:28px;" name="transferDate" size="12" maxlength="10" class="BigInput" value="" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"/>
                </td>
            </tr>

            <tr class="borderNone">
                <td width="30%" class="color">实际复职日期：</td>
                <td width="70%">
                    <input type="text" id="actualDataBef" style="width: 158px;height:28px;" name="transferDate" size="12" maxlength="10" class="BigInput" value="" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"/>
                    至
                    <input type="text" id="actualDataAft" style="width: 158px;height:28px;" name="transferDate" size="12" maxlength="10" class="BigInput" value="" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"/>
                </td>
            </tr>

            <tr class="borderNone">
                <td width="30%" class="color">复职原因：</td>
                <td width="70%">
                   <input type="text" name="explain" id="explain" class="BigStatic" style="width: 158px;height:28px;"></input>
                </td>
            </tr>
            <tr class="borderNone">
                <td width="30%" class="color">复职手续办理：</td>
                <td width="70%">
                    <input type="text" name="formality" id="formality" class="BigStatic" style="width: 158px;height:28px;"></input>
                </td>
            </tr>
            <tr class="borderNone">
                <td colspan="2" style="text-align: center">
                    <a href="javascript:;" class="btnsava" onclick="ajaxforms(1)"><fmt:message code="global.lang.query"/></a>
                    <a href="javascript:;" style="margin-left: 10px" class="btnsava"  onclick="ajaxforms(2)"><fmt:message code="global.lang.report"/></a>
                    <%--<a href="javascript:;" style="margin-left: 10px" class="btnsava chongtian"  ><fmt:message code="global.lang.refillings"/></a>--%>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<div id="pagediv" style="display: none;">
    <table cellspacing="0" cellpadding="0" style="border-collapse:collapse;" >
        <thead>
        <tr>
            <%--<th style="width: 40px;">选择</th>--%>
                <th style="width: 40px;">选择</th>
                <th>复职人员</th>
                <th>担任职务</th>
                <th>复职类型</th>
                <th>拟复职日期</th>
                <th>工资恢复日期</th>
                <th>操作</th>
        </tr>
        </thead>
        <tbody id="trList">

        </tbody>
    </table>
    <div class="right" style="margin-right: 10%;">
        <!-- 分页按钮-->
        <div class="M-box3" id="dbgz_pagesd"></div>
    </div>
</div>
<script>
    $.ajax({
        type:'get',
        url:'/hr/manage/fuZhiList?parentNo=HR_STAFF_REINSTATEMENT',
        dataType:'json',
        success:function(res){
            var str='';
            if(res){
                $.each(res.obj,function(index,item){
                    str+='<option value="'+item.codeName+'">'+item.codeName+'</option>'
                });
                $('#rehabType').append(str);
            }
        }
    });
    $('.addControls').click(function () {
        user_id='personnel';
        $.popWindow("/common/selectUser");
    })
    $('.cleardate').click(function () {
        $('#personnel').attr('username','');
        $('#personnel').attr('dataid','');
        $('#personnel').attr('user_id','');
        $('#personnel').attr('userprivname','');
        $('#personnel').val('');
    })
    var data={};
    $('#addPerson').click(function(){
        user_id="transferPerson";
        $.popWindow("/common/selectUser?0");
    })
    $('#closePerson').click(function(){
        $("#transferPerson").val("");
        $("#transferPerson").attr("user_id","");
        $("#transferPerson").attr("dataid","");
        $("#transferPerson").attr("username","");
        $("#transferPerson").attr("userprivname","");
    })

    function ajaxforms(type) {
        if(type ==1){
            $('.query').hide();
            $('#pagediv').show();
            //查询
            data={
                page:1,//当前处于第几页
                pageSize:10,//一页显示几条
                useFlag:true,
                reinstatementPerson:$("#personnel").attr("user_id"),
                reappointmentType:$("#rehabType").find("option:selected").val(),
                applicationDateBef:$("#applyDataBef").val(),
                applicationDateAft:$("#applyDataAft").val(),
                reappointmentTimeFactBef:$("#actualDataBef").val(),
                reappointmentTimeFactAft:$("#actualDataAft").val(),
                reappointmentState:$("#explain").val(),
                materialsCondition:$("#formality").val()
            }
            queryInit(data);
        }
        if(type ==2) {
            //导出
            var transferPerson = $("#personnel").attr("user_id");
            var transferType = $("#rehabType").find("option:selected").text();
            var transferDateStart = $("#applyDataBef").val();
            var transferDateEnd = $("#applyDataAft").val();
            var transferEffectiveDateStart = $("#actualDataBef").val();
            var transferEffectiveDateEnd = $("#actualDataAft").val();
            var reappointmentState = $("#explain").val();
            var materialsCondition = $("#formality").val();
            if (transferPerson != undefined) {

            window.location.href = '/hr/manage/selAllRehabBy?reinstatementPerson=' + transferPerson +
                '&transferType=' + transferType +
                '&applicationDateBef=' + transferDateStart +
                '&applicationDateAft=' + transferDateEnd +
                '&reappointmentTimeFactBef=' + transferEffectiveDateStart +
                '&reappointmentTimeFactAft=' + transferEffectiveDateEnd +
                '&reappointmentState=' + reappointmentState +
                '&materialsCondition=' + materialsCondition +
                '&export=1'
            }else{
                window.location.href = '/hr/manage/selAllRehabBy?transferType=' + transferType +
                    '&applicationDateBef=' + transferDateStart +
                    '&applicationDateAft=' + transferDateEnd +
                    '&reappointmentTimeFactBef=' + transferEffectiveDateStart +
                    '&reappointmentTimeFactAft=' + transferEffectiveDateEnd +
                    '&reappointmentState=' + reappointmentState +
                    '&materialsCondition=' + materialsCondition +
                    '&export=1'
            }
            return;

        }
    }

    function queryInit(condition) {
        var ajaxPage={
            data:condition,
            page:function () {
                var me=this;
                $.ajax({
                    type:'get',
                    url:'/hr/manage/selAllRehabBy',
                    dataType:'json',
                    data:me.data,
                    success:function(res){
                        var str='';
                        var str_s='';
                        var datas=res.obj;
                        if(datas.length > 0){
                            for(var i=0;i<datas.length;i++){
                                str+='<tr data-id="'+datas[i].reinstatementId+'">' +
                                    '<td><input type="checkbox" name="checkChild"></td>' +
                                    '<td>'+dataundefined(datas[i].reinstatementPerson)+'</td>' +
                                    '<td>'+dataundefined(datas[i].nowPosition)+'</td>' +
                                    '<td>'+dataundefined(datas[i].reappointmentType)+'</td>' +
                                    '<td>'+dataundefined(datas[i].reappointmentTimePlan)+'</td>' +
                                    '<td>'+dataundefined(datas[i].firstSalaryTime)+'</td>' +
                                    '<td>' +
                                    '<a href="javascript:;" class="detailsData">查看详情</a>' +
                                    '<a href="javascript:;" class="editData" style="margin: 0 10px;">编辑</a>' +
                                    '<a href="javascript:;" class="deleteData" style="color: red">删除</a>' +
                                    '</td>' +
                                    '</tr>'
                            }
//                            str_s='<tr><td colspan="7"><label style="cursor: pointer;"><input style="cursor: pointer;" type="checkbox" class="checkedAll"><span>全选</span></label><a href="javascript:;" class="deleteAll"><img src="/img/file/icon_fileDelete.png" style="margin-right: 4px;margin-left: -2px;margin-bottom: 3px;" alt="">删除</a></td></tr>'
                       }

                        $('#trList').html(str+str_s);
                        me.pageTwo(res.totleNum,me.data.pageSize,me.data.page)

                    }
                });

            },
            pageTwo:function (totalData, pageSize,indexs) {
                var mes=this;
                $('#dbgz_pagesd').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    jump: true,
                    coping: true,
                    homePage:'',
                    endPage: '',
                    current:indexs||1,
                    callback: function (index) {
                        mes.data.page=index.getCurrent();
                        mes.page();
                    }
                });
            }
        }
        ajaxPage.page();
    }

    function dataundefined(data) {
        if(data == undefined){
            return '';
        }else {
            return data;
        }
    }


    //        删除
    $('#trList').on('click','.deleteData',function () {
        var dataId=$(this).parents('tr').attr('data-id');
        deleteData(dataId);
    })

    //        点击编辑
    $('#trList').on('click','.editData',function () {
        var dataId=$(this).parents('tr').attr('data-id');
        parent.$('[name="notices"]').attr('src','/hr/manage/rehabNewedit?id='+dataId);
    })
    //        点击全选
    $('#trList').on('click','.checkedAll',function () {
        var state=$(this).prop('checked');
        if(state == true){
            $(this).prop('checked',true);
            $('input[name="checkChild"]').prop('checked',true);
        }else{
            $(this).prop('checked',false);
            $('input[name="checkChild"]').prop('checked',false);
        }
    })
    //        点击复选框
    $('#trList').on('click','input[name="checkChild"]',function () {
        var state=$(this).prop('checked');
        if(state == true){
            $(this).prop('checked',true);
        }else {
            $('#trList').find('.checkedAll').prop('checked',false);
            $(this).prop('checked',false);
        }
        var childCheck=$('#trList').find('input[name="checkChild"]');
        for(var i=0;i<childCheck.length;i++){
            var stateChild=$(childCheck[i]).prop('checked');
            if(state != stateChild){
                return
            }
        }
        $('#trList').find('.checkedAll').prop('checked',state);
    })
    //        点击删除按钮
    $('#trList').on('click','.deleteAll',function () {
        var deleteId='';
        $('#trList').find('input[name="checkChild"]:checked').each(function () {
            deleteId+=$(this).parents('tr').attr('data-id')+',';
        })
        deleteData(deleteId,data);
    })

    $('#trList').on('click','.detailsData',function () {
        var dataId=$(this).parents('tr').attr('data-id');
        $.popWindow('/hr/manage/hrRehabDetail?reinstatementId='+dataId, '员工复职信息详情', '0', '0', '1300px', '600px');
    })


    function deleteData(data,condition) {
        layer.confirm('确定删除该条数据吗？', {
            btn: ['确定','取消'], //按钮
            title:"删除"
        }, function(){
            //确定删除，调接口
            $.ajax({
                type:'post',
                url:'/hr/manage/delRehab',
                dataType:'json',
                data:{
                    reinstatementId:data
                },
                success:function(res){
                    if(res.flag){
                        layer.msg('删除成功！', { icon:6});
//                        ajaxPage.page();
                        window.location.href = "/hr/manage/rehabManage";
                    }else {
                        layer.msg('删除失败！', { icon:5});
                    }

                }
            })

        }, function(){
            layer.closeAll();
        });
    }
</script>
</body>
</html>


